﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TicketSeller
{
    [Serializable]
    public class ServerNode
    {
        public string Name { set; get; }

        public int Rank { set; get; }

        public TicketsCollection Tickets { set; get; }

        private IList<string> replicatedAt = new List<string>( );

        public IList<string> ReplicatedAt
        {
            get
            {
                return replicatedAt;
            }
        }

        public ServerNode()
        {

        }

        public ServerNode(string name)
        {
            Name = name;
        }

        public ServerNode(string name, int rank)
        {
            Name = name;
            Rank = rank;
        }

        public ServerNode( TicketsCollection tickets)
        {
            Tickets = tickets; 
        }

        public ServerNode( string name, TicketsCollection tickets)
        {
            Name    = name;
            Tickets = tickets;
        }

        public ServerNode(string name, int rank, TicketsCollection tickets)
        {
            Name = name;
            Rank = rank;
            Tickets = tickets;
        }

        public override bool Equals( object obj)
        {
            ServerNode node = (ServerNode)obj;
            return Name.Equals(node.Name);
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode( );
        }

        public ServerNode replicateAt(string serverName)
        {
            replicatedAt.Add(serverName);
            return this;
        }

    }
}
